package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.dao.LogisticsPathDao;
import com.yidu.logisticssystem.entity.LogisticsPath;
import com.yidu.logisticssystem.service.LogisticsPathService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 路线表(LogisticsPath)表服务实现类
 *
 * @author makejava
 * @since 2021-03-08 16:46:51
 */
@Service("logisticsPathService")
public class LogisticsPathServiceImpl implements LogisticsPathService {
    @Resource
    private LogisticsPathDao logisticsPathDao;

    /**
     * 通过ID查询单条数据
     *
     * @param pathId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsPath queryById(Integer pathId) {
        return this.logisticsPathDao.queryById(pathId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsPath> queryAllByLimit(int offset, int limit) {
        return this.logisticsPathDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsPath 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPath insert(LogisticsPath logisticsPath) {
        this.logisticsPathDao.insert(logisticsPath);
        return logisticsPath;
    }

    /**
     * 修改数据
     *
     * @param logisticsPath 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPath update(LogisticsPath logisticsPath) {
        this.logisticsPathDao.update(logisticsPath);
        return this.queryById(logisticsPath.getPathId());
    }

    /**
     * 通过主键删除数据
     *
     * @param pathId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer pathId) {
        return this.logisticsPathDao.deleteById(pathId) > 0;
    }

    @Override
    public List<LogisticsPath> queryAll(LogisticsPath logisticsPath) {
        return logisticsPathDao.queryAll(logisticsPath);
    }
}
